package com.zyh.arraydemo;

public class ArrayDemo4 {
    public static void main(String[] args) {
        int[] arr = {5, 12, 90, 18, 77, 76, 45, 28, 59, 72};
        int[] newArr = new int[arr.length + 1];
//        老数组的0-1的元素放到新数组的0-1里面
        for (int i = 0; i < 2; i++) {
            newArr[i] = arr[i];
            System.out.print(arr[i] + " ");
        }
        System.out.println();
//        老数组的2-9的元素放到新数组的3-10里面
        for (int i = 2; i < arr.length; i++) {
            newArr[i + 1] = arr[i];
            System.out.print(arr[i] + " ");
        }
        System.out.println();
//        将新数组的newArr[2]赋值为222
        newArr[2] = 222;
//        漂亮打印数组
        System.out.print("[");
        for (int i : newArr) {
            System.out.print(i + " ");
        }
        System.out.print("]");
    }
}
